#include "CoCoA/library.H"
#include <sstream>
using namespace CoCoA;
using namespace std;

template <typename PrintableType> string ToString(PrintableType po){
  ostringstream oss;
  oss << po;
  return oss.str();
}


void program()
{
  GlobalManager CoCoAFoundations;
  const	int Nvars=1;
  SparsePolyRing P = NewPolyRing(RingQ(), symbols("x")); // QQ[x,y];
  SparsePolyRing Q = NewPolyRing(RingQ(), symbols("x")); // QQ[x,y];
  const vector<RingElem>& x = indets(P);
  const vector<RingElem>& y = indets(Q);
  // symbol x1="x", x2="x";

  GlobalOutput() << "the string x[0]==y[0]?: "<< (ToString(x[0]) == ToString(y[0])) <<  endl;
  GlobalOutput() << ToString(x[0]) << "+"<< ToString(y[0]) <<  endl;
  // GlobalOutput() << "x1==x2?: "<< (x1 == x2) <<  endl;
  // GlobalOutput() << "x1==x[0]?: "<< (x1 == x[0]) <<  endl;
  
  RingElem f = power((power(x[0],6) - 1),2)*(x[0]-2); // f = x^96-y^96
  GlobalOutput() << "f: "<< f <<  endl;

  RingElem g = power(y[0],6) - 1; // f = x^96-y^96
  // FacInfo contains 3 fields:
  //   myFactors         - a vector of irreducible factors
  //   myExponents       - a vector of the corresponding multiplicities
  //   myRemainingFactor - an unfactored part (e.g. the content)

  // GlobalOutput() <<  (f == g) <<  endl;
  GlobalOutput() <<  (P == Q) <<  endl;
  // element compare must in the same ring
}

int main()
{
  try
  {
    program();
    return 0;
  }
  catch (const CoCoA::ErrorInfo& err)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT CoCoA error";
    ANNOUNCE(err);
  }
  catch (const std::exception& exc)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT std::exception: " << exc.what() << endl;
  }
  catch(...)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT UNKNOWN EXCEPTION" << endl;
  }
  return 1;
}


